#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>

static int counter = 0;
#define LOOPS 10000000

static void *thread(void *unused)
{
    int i;
    for(i = 0; i < LOOPS; i++)
        counter++;
        return (void *)0;
}

int main()
{

    pthread_t t1, t2;
    pthread_create(&t1, NULL, thread, NULL);
    pthread_create(&t2, NULL, thread, NULL);
    //等待
    pthread_join(t1, NULL);
    pthread_join(t2, NULL);

    printf("Counter=%d\n", counter);

    return 0;
}